<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="../lib/vue.js"></script>
    <link rel="stylesheet" href="../lib/animate.min.css">
    <style>
        li {
            border: 1px dashed #999;
            margin: 5px;
            line-height: 35px;
            padding-left: 5px;
            width: 100%;
        }
        li:hover{
            background-color: seagreen;
        }
        .v-enter,
        .v-leave-to{
            opacity: 0;
            transform: translateY(80px);
            position: absolute;
        }
        .v-enter-active,
        .v-leave-active{
            transition: all 0.6s ease;
        }
        .v-move{
            transition: all 0.6 ease;
        }

    </style>
</head>

<body>
    <div id="app">
        <div>
            <label>
                ID:
                <input type="text" v-model="id">
            </label>
            <label>
                NAME:
                <input type="text" v-model="name">
            </label>
            <button @click="add">添加</button>
        </div>
        <!-- <ul> -->
            <!-- 通过指定tag属性 指定transition渲染为ul 不指定渲染为span-->
            <transition-group appear tag="ul">
                <li v-for="item in list" :key="item.id" @click="move(item.id)">
                    {{item.id}}--{{item.name}}
                </li>
            </transition-group>
        <!-- </ul> -->

    </div>

    <script>
        var vm = new Vue({
            el: '#app',
            data: {
                id:'',
                name:'',
                list: [
                    { id: 1, name: '奥迪' },
                    { id: 2, name: '宝马' },
                    { id: 3, name: '奔驰' }
                ]
            },
            methods: {
                add(){
                    this.list.push({id:this.id,name:this.name});
                },
                move(i){
                    this.list.splice(i,1)
                }
            },
            directives: {

            },
            filters: {

            }
        })

    </script>
</body>

</html>